/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package model;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

/**
 *
 * @author NGUYENHOANG
 */
public class DataOperations {
    public DataOperations() {
        conn = this.getConnection();
        try {
            st = conn.createStatement();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    private String getConnectionUrl() {
        this.url = "jdbc:mysql://";
        this.serverName = "localhost:3306";
        this.databaseName = "mymap";
        this.userName = "root";
        this.password = "1234567";
        return url + serverName + ";databaseName=" + this.databaseName;
    }

    private Connection getConnection() {
        try {
            Class.forName("com.mysql.jdbc.Driver").newInstance ();
            conn = DriverManager.getConnection(getConnectionUrl(),this.userName,this.password);

        } catch (Exception e) {
            e.printStackTrace();
        }
        if(conn!=null)
            return conn;
        return null;
    }

    private Connection conn;
    private Statement st;
    private String url;
    private String serverName;
    private String databaseName;
    private String instanceName;
    private String userName;
    private String password;
    private String sql;
}
